/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-10-04
 * Time: 23:42
 */
public class Test99 {

    public static int majorityElement(int[] nums) {
        int cn = nums[0], count = 1;

        for(int i = 1; i < nums.length; i++) {
            if(cn == nums[i]) {
                count++;
            }else {
                if(count == 0) {
                    count = 1;
                    cn = nums[i];
                }
            }
        }
        return cn;
    }

    public static void main(String[] args) {
        int[] num = {3,2,3};
        System.out.println(majorityElement(num));
    }
}
